% plot modes and things

clear M
clear F

if 1 == 0
M = PetscBinaryRead('lossmat.bin');
F = PetscBinaryRead('prodmat.bin');
[v, e] = eigs(F, M);
[e, i] = sort(diag(e), 'descend');
end

N = length(v(:,1));
n = sqrt(N/2);
colormap('jet')
mode = 4;

p1 = v(1:2:end,i(mode)); p1 = p1 * sign(p1(1));
p2 = v(2:2:end,i(mode)); p2 = p2 * sign(p2(1));

figure(1)
subplot(1,2,1)
contourf(-reshape(p1,n,n),100), shading flat, axis square, colorbar, title(['group 1, mode ',num2str(mode)])
subplot(1,2,2)
contourf(-reshape(p2,n,n),340), shading flat, axis square, colorbar, title(['group 2, mode ',num2str(mode)])